/*************************************************
Author: byron
Date: 05/07/2013
Description:
Notes: 
*************************************************/

#ifndef __CAcademyBossMgr_h__
#define __CAcademyBossMgr_h__

#include "commclass.h"
#include "CAcademyBossData.h"
#include "CTSizeString.h"
#include "MsgTips.pb.h"

class CPlayerBaseInfo;
class CPlayerDetailInfo;
class CPlayerCacheData;
class CPlayerOnlineData;
class CPlayerSnsCommInfo;
class MsgReqAcademyBoss;
class MsgAnsAcademyBoss;
class CDropItem;
class CBattleRole;
class CActCfgData;
class MsgReqGMPlayer;
class MsgAnsGMPlayer;
class MsgAcademyBossMonster;

class CAcademyBossCmdData
{
public:
    CAcademyBossCmdData()
    {
        Clear();
    }

    void Clear()
    {
        _shCloseActID = 0;
        _iFootboyReputation = 0;
        _iFootboyExp = 0;
        _iFootboyContribu = 0;
        _iFootboySilver = 0;
        _iFiftyReputation = 0;
        _iFiftyExp = 0;
        _iFiftyContribu = 0;
        _iFiftySilver = 0;
        _iKillReputation = 0;
        _iKillExp = 0;
        _iKillContribu = 0;
        _iKillSilver = 0;
        _stKillSelfTips.Clear();
        _stKillOtherTips.Clear();
        _stKillFirstTips.Clear();
        _stFiftySelfTips.Clear();
        _stFiftyOtherTips.Clear();
        _stFootboySelfTips.Clear();
        _stFootboyOtherTips.Clear();
    }

    virtual ~CAcademyBossCmdData()
    {
    }

    short GetCloseActID() const {return _shCloseActID;}
    int GetFootboyReputation() const {return _iFootboyReputation;}
    int GetFootboyExp() const {return _iFootboyExp;}
    int GetFootboyContribu() const {return _iFootboyContribu;}
    int GetFootboySilver() const {return _iFootboySilver;}
    int GetFiftyReputation() const {return _iFiftyReputation;}
    int GetFiftyExp() const {return _iFiftyExp;}
    int GetFiftyContribu() const {return _iFiftyContribu;}
    int GetFiftySilver() const {return _iFiftySilver;}
    int GetKillReputation() const {return _iKillReputation;}
    int GetKillExp() const {return _iKillExp;}
    int GetKillContribu() const {return _iKillContribu;}
    int GetKillSilver() const {return _iKillSilver;}

    void SetCloseActID(short shVal) {_shCloseActID = shVal;}
    void SetFootboyReputation(int iVal) {_iFootboyReputation = iVal;}
    void SetFootboyExp(int iVal) {_iFootboyExp = iVal;}
    void SetFootboyContribu(int iVal) {_iFootboyContribu = iVal;}
    void SetFootboySilver(int iVal) {_iFootboySilver = iVal;}
    void SetFiftyReputation(int iVal) {_iFiftyReputation = iVal;}
    void SetFiftyExp(int iVal) {_iFiftyExp = iVal;}
    void SetFiftyContribu(int iVal) {_iFiftyContribu = iVal;}
    void SetFiftySilver(int iVal) {_iFiftySilver = iVal;}
    void SetKillReputation(int iVal) {_iKillReputation = iVal;}
    void SetKillExp(int iVal) {_iKillExp = iVal;}
    void SetKillContribu(int iVal) {_iKillContribu = iVal;}
    void SetKillSilver(int iVal) {_iKillSilver = iVal;}

    MsgTips& GetKillSelfTips(){return _stKillSelfTips;}
    MsgTips& GetKillOtherTips(){return _stKillOtherTips;}
    MsgTips& GetKillFirstTips(){return _stKillFirstTips;}
    MsgTips& GetFiftySelfTips(){return _stFiftySelfTips;}
    MsgTips& GetFiftyOtherTips(){return _stFiftyOtherTips;}
    MsgTips& GetFootboySelfTips(){return _stFootboySelfTips;}
    MsgTips& GetFootboyOtherTips(){return _stFootboyOtherTips;}

private: 
    short   _shCloseActID;
    int     _iFootboyReputation;
    int     _iFootboyExp;
    int     _iFootboyContribu;
    int     _iFootboySilver;
    int     _iFiftyReputation;
    int     _iFiftyExp;
    int     _iFiftyContribu;
    int     _iFiftySilver;
    int     _iKillReputation;
    int     _iKillExp;
    int     _iKillContribu;
    int     _iKillSilver;
    MsgTips _stKillSelfTips;
    MsgTips _stKillOtherTips;
    MsgTips _stKillFirstTips;
    MsgTips _stFiftySelfTips;
    MsgTips _stFiftyOtherTips;
    MsgTips _stFootboySelfTips;
    MsgTips _stFootboyOtherTips;
};

class CAcademyBossMgr
{
public:
    enum CMD_ACADEMY_BOSS_SUB_TAG
    {
        CMD_ACADEMY_BOSS_SUB_BUFF = 1,            //购买梅林祝福
        CMD_ACADEMY_BOSS_SUB_REVIVE = 2,          //使用金币复活
        CMD_ACADEMY_BOSS_SUB_BATTLE = 3,          //进入战斗
        CMD_ACADEMY_BOSS_SUB_INSPIRE = 4,         //施加鼓舞状态
        CMD_ACADEMY_BOSS_SUB_DEAD = 5,            //角色死亡
        CMD_ACADEMY_BOSS_SUB_ATK_RANK = 6,        //怪物血量+攻击伤害榜+主角名次及攻击伤害
        CMD_ACADEMY_BOSS_SUB_ROLE_INFO = 7,       //内部调用进行数据准备不检查是否登录不发响应包
    };

    enum ENUM_ACADEMY_BOSS_MON_TAG
    {
        ENUM_ACADEMY_BOSS_MON_LEFT = 1,          //左侍从
        ENUM_ACADEMY_BOSS_MON_RIGHT = 2,         //右侍从
        ENUM_ACADEMY_BOSS_MON_BOSS = 3,          //试练使者
    };

    enum ENUM_ACADEMY_BOSS_MACRO_TAG
    {
        ACADEMY_BOSS_INSPIRE_TRIGGER = 50,        //千分比 鼓舞状态触发条件
        ACADEMY_BOSS_MERLIN_GOLD_INIT = 2,       //梅林祝福金币初始价格
        ACADEMY_BOSS_MERLIN_GOLD_ADD = 0,         //梅林祝福金币价格递增量
        ACADEMY_BOSS_MERLIN_GOLD_MAX = 100,       //梅林祝福金币价格上限
        ACADEMY_BOSS_DEAD_GOLD_INIT = 5,         //死亡复活金币初始价格
        ACADEMY_BOSS_DEAD_GOLD_ADD = 0,          //死亡复活金币价格递增量
        ACADEMY_BOSS_DEAD_GOLD_MAX = 100,         //死亡复活金币价格上限
        ACADEMY_BOSS_DEAD_WAIT_TIME = 30,         //死亡冷却时长
        ACADEMY_BOSS_FIGHT_WAIT_TIME = 10,        //战斗冷却时长
        ACADEMY_BOSS_NOTIFY_WAIT_TIME = 5,        //下发怪物血量及排名榜间隔
        ACADEMY_BOSS_MONSTER_BORN_TIME = 120,     //活动开启后怪物出生时长
    };

    CAcademyBossMgr()
    {
        _stActList.Clear();//这个很关键
        _stRandList.Clear();//必须初始化
        _stMonList.Clear();//必须初始化
    }

    virtual ~CAcademyBossMgr()
    {
    }

    int GetInspireNum() const {return _iInspireNum;}
    int GetAcademyType() const {return _iAcademyType;}
    int GetMonsterType() const {return _iMonsterType;}

    void SetInspireNum(int iVal){_iInspireNum = iVal;}
    void SetAcademyType(int iType){_iAcademyType = iType;}
    void SetMonsterType(int iType){_iMonsterType = iType;}

    bool IsMapIDNeedUpdateDB(const unsigned int uiMapID);

	int CheckRoleEnterAndBattle(CPlayerBaseInfo& stPlayerBase,
            int iEnterAcademy);

    int EnterScene(const unsigned int uiMapID, CPlayerBaseInfo& stPlayerBase);
   
    int LeaveScene();

    int ActOpen(CActCfgData& stActCfgData);

    int SetAcademyBossMonRole(CPlayerBaseInfo& stPlayerBase,
            CPlayerDetailInfo& stPlayerDetail,
            CPlayerOnlineData& stPlayerOnline,
            CPlayerSnsCommInfo& stPlayerSnsComm, MsgReqAcademyBoss& stReq);

    int ActClose(CActCfgData& stActCfgData);

    unsigned int GetAcademyBossMapID(int iAcademyType);

    int GetAcademyTypeByMapID(unsigned int uiMapID);

    int GetAcademyTypeByActID(short shActID);

    int InitPlayerData(CPlayerCacheData& stPlayerCache, int iAcademyType);

    int GetMerlinGold(CPlayerCacheData& stPlayerCache, int iAcademyType);

    int GetReviveGold(CPlayerCacheData& stPlayerCache, int iAcademyType);

    bool IsValidAcademyType(int iAcademyType);

    bool IsValidMonsterType(int iMonsterType);

    int BuyMerlin(CPlayerBaseInfo& stPlayerBase,
            CPlayerCacheData& stPlayerCache, MsgReqAcademyBoss& stReq,
            MsgAnsAcademyBoss& stAns);

    int AddInspire(CPlayerCacheData& stPlayerCache, int iAcademyType,
            int iAddNum);

    int DeadRevive(CPlayerBaseInfo& stPlayerBase,
            CPlayerCacheData& stPlayerCache, MsgReqAcademyBoss& stReq,
            MsgAnsAcademyBoss& stAns);

    int GetMonsterHP(CAcademyBossMonster& stAcademyMon, int iMonsterType);

    int SetMonsterHP(CAcademyBossMonster& stAcademyMon, int iMonsterType,
            int iHP);

    MsgAcademyBossMonster& GetMsgMonRole(CAcademyBossMonster& stAcademyMon,
            int iMonsterType);

    CPlayerEquip& GetMonRoleEquip(CAcademyBossMonster& stAcademyMon,
            int iMonsterType);

    int GetMonsterHPMax(CAcademyBossMonster& stAcademyMon, int iMonsterType);

    int GetAllMonsterHPMax(CAcademyBossMonster& stAcademyMon);

    unsigned int GetMonsterID(CAcademyBossMonster& stAcademyMon,
            int iMonsterType);

    unsigned int GetMonGroupID(CAcademyBossMonster& stAcademyMon,
            int iMonsterType);

    int BossBattle(CPlayerBaseInfo& stPlayerBase,
            CPlayerDetailInfo& stPlayerDetail,
            CPlayerOnlineData& stPlayerOnline, CPlayerCacheData& stPlayerCache,
            MsgReqAcademyBoss& stReq, MsgAnsAcademyBoss& stAns, CAcademyBossCmdData& stCmdData);

    int ReviseBeforeBattle(int iBossBattleID);

    int DealMonsterAfterBattle(CBattleRole& stBattleObj, unsigned int uiGID,
            int iAcademyType, int iMonsterType, CAcademyBossCmdData& stCmdData);

    int GetTriggerAddNum(int iValNow, int iValOld, int iValMax, int iRate);

    int DealPlayerAfterBattle(CPlayerOnlineData& stPlayerOnline,
            CPlayerCacheData& stPlayerCache, MsgAnsAcademyBoss& stAns,
            int iBattleResult, int iAcademyType, int iMonsterType,
            CAcademyBossCmdData& stCmdData);

    int GMSetMonsterHP(short shActID, int iNewHP, int iMonsterType);

    int GMSetWorldLevel(short shActID, int iNewLevel);

    void GMGetAcademyBoss(int iAcademyType,
            CTSizeString<MAX_BATTLE_NAME_BUFF>& szNameStr);

    int GMDealAcademyBoss(MsgReqGMPlayer& stReq, MsgAnsGMPlayer& stAns);

    void AcademyBossNotify(int iAcademyType);

    void AcademyBossNotify(unsigned int uiGID, int iSubCmd, int iAcademyType,
            bool bNotifySelf);

    void AcademyBossNotify(unsigned int uiGID, int iSubCmd, int iAcademyType,
            MsgAnsAcademyBoss& stAns);

    bool IsFirstKillBoss(int iAttackAcademy);

    void AcademyBossNotifyTip(CPlayerBaseInfo& stPlayerBase, int iAcademyType,
            int iMonsterType, CAcademyBossCmdData& stCmdData);

    void AcademyBossSceneNotify(int iAcademyType);

    void GetAcademyBossMonster(MsgAnsAcademyBoss& stAns, int iAcademyType);

    void GetAcademyBossMonRole(int iAcademyType, int iMonsterType,
            MsgAcademyBossMonster& stMsgMonster);

    void GetAcademyBossRole(CPlayerCacheData& stPlayerCache,
            MsgAnsAcademyBoss& stAns, int iAcademyType);

    void GetAcademyBossKiller(MsgAnsAcademyBoss& stAns, int iAcademyType);

    void GetAcademyBossAtkRank(MsgAnsAcademyBoss& stAns, int iAcademyType);

    int GetAcademyBossSceneInfo(CPlayerCacheData& stPlayerCache,
            MsgAnsAcademyBoss& stAns, int iAcademyType);

    int AcademyBossRewardItem(unsigned int uiGID, int iRepu, int iExp,
            int iContri, int iSilver, CDropItem& stDropItem);

    int AcademyBossRoleReward(CPlayerCacheData& stPlayerCache,
            MsgAnsAcademyBoss& stAns, int iAcademyType, int iMonsterType,
            CAcademyBossCmdData& stCmdData);

    int AcademyBossFinishReward(int iAcademyType);

private: 
    bool    _bKill;
    bool    _bFifty;
    bool    _bFootboyKill;
    int     _iInspireNum;
    int     _iAcademyType;
    int     _iMonsterType;
    CAcademyBossAct _stActList;
    CAcademyBossRandom _stRandList;
    CAcademyBossMonList _stMonList;
};

#endif //__CAcademyBossMgr_h__

